package com.ztgf.shopping.api.client.template;


import com.baomidou.mybatisplus.mapper.EntityWrapper;
import com.baomidou.mybatisplus.mapper.Wrapper;
import com.baomidou.mybatisplus.plugins.Page;
import com.ztgf.common.constant.Result;
import com.ztgf.common.enums.CodeEnum;
import com.ztgf.shopping.models.bo.template.TempletModuleBO;
import com.ztgf.shopping.models.bo.template.TempletModuleSaveBO;
import com.ztgf.shopping.models.dto.template.TempletModuleDTO;
import com.ztgf.shopping.models.service.template.ITempletModuleService;
import com.ztgf.shopping.models.vo.template.TempletModuleVO;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.apache.dubbo.config.annotation.DubboReference;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * <p>
 * 模版功能模块  前端控制器
 * </p>
 *
 * @author YUE
 * @since 2020-05-23
 */
@RestController
@RequestMapping("/api/templetModule")
@Slf4j
@Api(value = "TempletModuleApiController",tags = "模版功能模块表接口")
public class TempletModuleApiController {
    @DubboReference
    private ITempletModuleService iTempletModuleService;

    @PostMapping("/get")
    @ApiOperation(value = "根据id查找",notes = "根据id查找")
    @ApiImplicitParam(name = "id",value = "id",required = true,paramType = "query", dataType = "Long")
    public Result<TempletModuleDTO> get(Long id){
        if(id == null){
            return new Result<>(CodeEnum.FAIL_100002 );
        }
        TempletModuleDTO templetModuleDTO = iTempletModuleService.selectById(id);
        return new Result<>(templetModuleDTO);
    }

    @ApiOperation(value = "模版功能模块表列表",notes = "模版功能模块表列表")
    @PostMapping("/queryPageList")
    public Result<Page<TempletModuleDTO>> queryPageList(TempletModuleBO templetModuleBO){
        Wrapper<TempletModuleDTO> wrapper = new EntityWrapper<>();
        Page<TempletModuleDTO> page = new Page<>(templetModuleBO.getPageNo(), templetModuleBO.getPageSize());
        page = iTempletModuleService.selectPage(page, wrapper);
        return new Result<>(page);
    }
}

